package com.train.pattern.strategy.v2.pay.way;


import com.train.pattern.strategy.v2.pay.Account;
import com.train.pattern.strategy.v2.pay.MsgResult;

/**
 * @author hugx
 * @create 2021-01-15 13:58
 */
public class JdPayStrategy implements PayStrategy {

    @Override
    public MsgResult pay(Account account, double totalMoney) {
        StringBuilder sb = new StringBuilder("欢迎使用");
        sb.append("京东白条\n").append("本次交易金额为").append(totalMoney).append(",开始扣款");
        System.out.println(sb.toString());
        //余额是否足够
        if (account.getBalance() < totalMoney) {
            return new MsgResult(500, "支付失败", "余额不足");
        } else {
            return new MsgResult(200, "支付成功", "支付金额" + totalMoney);
        }
    }
}
